home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / dflat2.zip / MOUSE.C < prev    next >
Text File  |  1991-02-17  |  2KB  |  80 lines

  1. /* ------------- mouse.c ------------- */
  2.  
  3. #include <stdio.h>
  4. #include <dos.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. #include "system.h"
  8.  
  9. static union REGS regs;
  10.  
  11. static void near mouse(int m1,int m2,int m3,int m4)
  12. {
  13.     regs.x.dx = m4;
  14.     regs.x.cx = m3;
  15.     regs.x.bx = m2;
  16.     regs.x.ax = m1;
  17.     int86(MOUSE, ®s, ®s);
  18. }
  19.  
  20. /* ---------- reset the mouse ---------- */
  21. void resetmouse(void)
  22. {
  23.     mouse(0,0,0,0);
  24. }
  25.  
  26. /* ----- test to see if the mouse driver is installed ----- */
  27. int mouse_installed(void)
  28. {
  29.     unsigned char far *ms;
  30.     ms = MK_FP(peek(0, MOUSE*4+2), peek(0, MOUSE*4));
  31.     return (ms != NULL && *ms != 0xcf);
  32. }
  33.  
  34. /* ------ return true if mouse buttons are pressed ------- */
  35. int mousebuttons(void)
  36. {
  37.     if (mouse_installed())
  38.         mouse(3,0,0,0);
  39.     return regs.x.bx & 3;
  40. }
  41.  
  42. /* ---------- return mouse coordinates ---------- */
  43. void get_mouseposition(int *x, int *y)
  44. {
  45.     if (mouse_installed())    {
  46.         mouse(3,0,0,0);
  47.         *x = regs.x.cx/8;
  48.         *y = regs.x.dx/8;
  49.     }
  50. }
  51.  
  52. /* -------- position the mouse cursor -------- */
  53. void set_mouseposition(int x, int y)
  54. {
  55.     if(mouse_installed())
  56.         mouse(4,0,x*8,y*8);
  57. }
  58.  
  59. /* --------- display the mouse cursor -------- */
  60. void show_mousecursor(void)
  61. {
  62.     if(mouse_installed())
  63.         mouse(1,0,0,0);
  64. }
  65.  
  66. /* --------- hide the mouse cursor ------- */
  67. void hide_mousecursor(void)
  68. {
  69.     if(mouse_installed())
  70.         mouse(2,0,0,0);
  71. }
  72.  
  73. /* --- return true if a mouse button has been released --- */
  74. int button_releases(void)
  75. {
  76.     if(mouse_installed())
  77.         mouse(6,0,0,0);
  78.     return regs.x.bx;
  79. }
  80.